package com.neu.view;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionListener;

import javax.swing.AbstractCellEditor;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;

public class PatientButtonEditor extends AbstractCellEditor implements TableCellEditor {
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -6546334664166791132L;

	private JPanel panel;

	private JButton button;

	private String on;

	public PatientButtonEditor(ActionListener actionListener) {

		initButton(actionListener);

		initPanel();

		panel.add(this.button, BorderLayout.CENTER);
	}

	private void initButton(ActionListener actionListener) {
		button = new JButton();

		button.addActionListener(actionListener);

	}

	private void initPanel() {
		panel = new JPanel();

		panel.setLayout(new BorderLayout());
	}

	@Override
	public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
		on = (String) value;

		button.setText("评估");

		return panel;
	}

	@Override
	public Object getCellEditorValue() {
		// TODO Auto-generated method stub
		return on;
	}
}
